package block_node

import (
	"golang.org/x/net/context"
	"block_proto"
	"strings"
	"fmt"
)

type BlockServer struct {

}

func (bs *BlockServer)Command(ctx context.Context, request *block_proto.CommandRequest) (*block_proto.CommandResponse, error)  {
	response := &block_proto.CommandResponse{}

	cmd := request.GetCommand()
	fields := strings.Split(cmd, " ")
	cmdType := fields[0]

	switch cmdType {
	case "pporfcpu", "pporfmem":
		response.Message = fmt.Sprintf("%v", cmd)
	case "hello":
		s := "What a fucking world!!!"
		response.Message = fmt.Sprintf("%s", s)
	default:
		response.Message = fmt.Sprintf("invalid command[%v]", cmd)
	}
	return response, nil
}

